import 'package:flutter/material.dart';

import 'wechat_util.dart';

class WechatPage extends StatefulWidget {
  @override
  _WechatPageState createState() => _WechatPageState();
}

class _WechatPageState extends State<WechatPage> {

  @override
  void initState() {
    super.initState();
    WechatUtil.instance.init();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
        title: Text('微信'),
    ),
    body: Column(children: [

      TextButton(
        onPressed: (){
          WechatUtil.instance.hasWeChat().then((value){
            print('是否按照微信: $value');
          });
        },
        child: Text('是否按照微信：'),),

      TextButton(
        onPressed: (){
          WechatUtil.instance.openWeChat();
        },
        child: Text('打开微信'),),

      TextButton(
        onPressed: (){
          WechatUtil.instance.shareText('我是Flutter分享的文字');
        },
        child: Text('分享文字'),),

      TextButton(
        onPressed: (){
          WechatUtil.instance.shareImage('');
        },
        child: Text('分享图片'),),

      TextButton(
        onPressed: (){
          WechatUtil.instance.login().then((value){
            print('是否按照微信: $value');
          });
        },
        child: Text('微信登录'),),

      TextButton(
        onPressed: (){

        },
        child: Text('微信支付'),),

    ],),
    );
  }

}